
use $datapath/clean/main_data.dta, clear 

************************************************
* Create variable labels: 

	label var Qp "phys"
	label var Np "phys holdings"
	label var Qe "ebook"
	label var Ne "ebook holdings"

			
************************************************
** run regressions - FEs:


eststo clear
		
** OLS effect on Qp & Qe
	eststo: reg Qp Np Ne i.year, vce(cluster lno)
	eststo: reg Qe Np Ne i.year, vce(cluster lno)

** FE effect on Qp & Qe
	eststo: areg Qp Np Ne i.year, absorb(lno) vce(cluster lno)
		estimates save causal_demand_Qp_FE, replace

	eststo: areg Qe Np Ne i.year, absorb(lno) vce(cluster lno)
		estimates save causal_demand_Qe_FE, replace

	
************************************************
** Table 2: 

local pattern prefix(/multicolumn{@span}{c}{) suffix(}) span erepeat(/cmidrule(lr){@span})

	esttab,  noomitted mtitles("Phys" "Ebook" "Phys" "Ebook") drop(*.year _cons) se replace  label nonotes star(* 0.10 ** 0.05 *** 0.01) scalars("r2_a $/overline{R^2}$") mgroups( "OLS" "FE", pattern(1 0 1 0) `pattern')  nocons


	esttab using "$tablepath/table2_circ_FE.tex",  noomitted mtitles("Phys" "Ebook" "Phys" "Ebook") drop(*.year _cons) se replace  label nonotes star(* 0.10 ** 0.05 *** 0.01) scalars("r2_a $/overline{R^2}$") mgroups( "OLS" "FE", pattern(1 0 1 0) `pattern')  nocons booktabs

	